package com.project.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.Random;

@Data
@ApiModel(value = "库存商品")
@TableName("t_stock_shop")
public class StockShopBean {
    @ApiModelProperty(hidden = true)
    @TableId("pk_shopId")
    private String shopId=generateId();

    @ApiModelProperty(value = "商品名")
    @TableField("s_name")
    private String name;
    @ApiModelProperty(value = "品牌名")
    @TableField("s_brand")
    private String brand;
    @ApiModelProperty(value = "类型")
    @TableField("s_type")
    private String type;
    @ApiModelProperty(value = "图片地址")
    @TableField("s_img")
    private String img;
    @ApiModelProperty(value = "库存数量")
    @TableField("s_num")
    private Integer num;
    @ApiModelProperty(value = "最新采购价")
    @TableField("s_newBuyPrice")
    private Integer newBuyPrice;
    @ApiModelProperty(value = "建议销售价")
    @TableField("s_salePrice")
    private Integer salePrice;

    public StockShopBean() {

    }

    public StockShopBean( String name, String brand, String type, String img, Integer num, Integer newBuyPrice) {
        this.name = name;
        this.brand = brand;
        this.type = type;
        this.img = img;
        this.num = num;
        this.newBuyPrice = newBuyPrice;
    }
    private String generateId() {
        // 生成随机字母
        Random random = new Random();
        char randomChar = (char) (random.nextInt(26) + 'A');
        // 获取当前时间戳
        long timestamp = new Date().getTime();
        // 截取时间戳后八位
        String id = Long.toString(timestamp).substring(5);
        // 组合成字符串
        String code = randomChar+id;
        return code;
    }


    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getNewBuyPrice() {
        return newBuyPrice;
    }

    public void setNewBuyPrice(Integer newBuyPrice) {
        this.newBuyPrice = newBuyPrice;
    }

    public Integer getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(Integer salePrice) {
        this.salePrice = salePrice;
    }

    @Override
    public String toString() {
        return "StockShopBean{" +
                "shopId='" + shopId + '\'' +
                ", name='" + name + '\'' +
                ", brand='" + brand + '\'' +
                ", type='" + type + '\'' +
                ", img='" + img + '\'' +
                ", num=" + num +
                ", newBuyPrice=" + newBuyPrice +
                ", salePrice=" + salePrice +
                '}';
    }
}
